package spm.project.rememberme;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;

public class Difficulty extends Activity{
	
	 RadioGroup radioGroup;
	Button SELECT;
	RadioButton easy , normal , hard;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.difficulty);
	//------- get actual device height & width ------------------
	DisplayMetrics metrics = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics(metrics);
	int height = metrics.heightPixels;
	int width = metrics.widthPixels;
	
	//------------------RADIOGROUP-------------------------------
	
	radioGroup= (RadioGroup) findViewById(R.id.radioGroup);	
	RelativeLayout.LayoutParams par = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
	par.setMargins((width*35)/100, (height*40)/100, 0, 0);
	radioGroup.setLayoutParams(par);
	easy = (RadioButton) findViewById(R.id.easy);
	easy.setTextSize((3*width)/100);
	normal = (RadioButton) findViewById(R.id.normal);
	normal.setTextSize((3*width)/100);

	hard = (RadioButton) findViewById(R.id.hard);
	hard.setTextSize((3*width)/100);

	//----------------- SELECT BUTTON ---------------------------
	SELECT = (Button) findViewById(R.id.SELECT);
	RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((width*33)/100, (height*7)/100);
	params.setMargins((width*33)/100, (height*65)/100, 0, 0);
	SELECT.setLayoutParams(params);
	SELECT.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	int checkedRadioButton = radioGroup.getCheckedRadioButtonId();
       	 
        	
        	 
        	switch (checkedRadioButton) {
        	  case R.id.easy : setTableGame(3,4);
        	                   	              break;
        	  case R.id.normal :setTableGame(4,5);
        			                      break;
        	  case R.id.hard : setTableGame(6,5);
        			                      break;
        	
        	}
        }
       
                });
	

		

	 
	
	}

	private void setTableGame (int x , int y){
		Intent tableGame = new Intent (this, SingleGame.class);
		tableGame.putExtra("column", x);
		tableGame.putExtra("row", y);
		startActivity(tableGame);
		finish();
	}
}
